package com.gupao.strategy;

/**
 * 测试类 Created by ktyan on 2017/5/23.
 */
public class StrategyTest
{
    public static void main(String args[])
    {
        int a = 10, b = 2;
        System.out.println("a = 10,b = 2 ");
        // 执行加法策略
        Context addContext = new Context(new AddStrategy());
        int addResult = addContext.calculate(a, b);
        System.out.println("a + b = " +addResult);
        
        // 执行减法策略
        Context subContext = new Context(new SubstractStrategy());
        int subResult = subContext.calculate(a, b);
        System.out.println("a - b = " + subResult);

        // 执行除法策略
        Context divContext = new Context(new DivisionStrategy());
        int divResult = divContext.calculate(a, b);
        System.out.println("a / b = " + divResult);
        // 执行乘法策略
        Context mulContext = new Context(new MultiplyStrategy());
        int mulResult = mulContext.calculate(a, b);
        System.out.println("a * b = " + mulResult);
    }
}
